
	******************************************************************
	**
	**
	**		NAME:		GUY GROSSMAN and YOTAM MARGALIT
	**		DATE: 		December 15, 2021
	**		PROJECT: 	Israel Hayom
	**		DETAILS: 	This code generates Table SI-15
	**		Version: 	Stata MP 16
	**
	******************************************************************
	
			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**

set scheme plotplainblind, permanently
clear
version 16
set more off

* Set the global

capture cd "~/dropbox/Israeli Newspapers Study/JOP_REPLICATION/Dataverse submission"

* Bring in dataset

use "Data/yeshuvlong_final.dta"

* Additional cleaning
	
replace israelhayom_percent_e=0 if israelhayom_percent_e==. & year<2007
replace israelhayom_percent=0 if israelhayom_percent==. & year<2007
replace israelhayom_percent_cumulative=0 if israelhayom_percent_cumulativ==. & year<2007

drop if area_num >25

keep if BIG_rightbloc!=.
tabulate year, gen(YEAR)

* gen a running number for election years 	
egen yr = group(year)
move yr year

gen lpop= log(potential)
gen ltd = log(travel_dist)

* generate turnout var

gen turnout = voters/potential
replace turnout = 1 if turnout>1
replace turnout = turnout*100
tab year, summ(turnout)

* population share by age group

gen pop_share1829 = pop_M_18_29 / pop_total 
gen pop_share3049 = pop_M_30_49 /pop_total
gen pop_share5065 = pop_M_50_65 /pop_total
gen pop_share66 = pop_M_66 / pop_total
gen pop_adult = pop_M_18_29 + pop_M_30_49 + pop_M_50_65 + pop_M_66
 
 foreach var in pop_share1829 pop_share3049 pop_share5065 pop_share66{
	replace `var'=0 if `var'<0
 }

tabstat ltd lpop age_median_08 matriccert_pcnt_08 europe_pcnt_08 asia_pcnt_08 pop_share1829 pop_share3049 pop_share5065 pop_share66, by(yr)

corr ltd lpop age_median_08 potential matriccert_pcnt_08 europe_pcnt_08  asia_pcnt_08 pop_share1829 pop_share3049 pop_share5065 pop_share66 if yr==4

* generate otherpapers var for attentativeness measure

egen otherpapers=rowtotal(maariv_percent haaretz_percent globes_percent marker_percent calcalist_percent israelpost_percent makorrishon_percent) if year==2006
	bysort area_num: egen otherpapers2006=max(otherpapers)
	drop otherpapers
	
* rename parties	

ren Pisrael_beitenu Pib
ren BIG_rightbloc BRB
ren israelhayom_percent_electionyear IHE

* rename instruments

ren secular_max IVsm
ren secular_max07H1 IVsm07H1
ren sec_max06h2_07H1 IVsm06h2_07H1

tabstat IVsm IVsm07H1 IVsm06h2_07H1,  by(year)
corr IVsm IVsm07H1 IVsm06h2_07H1
drop IVsm

bysort area_num: egen IVsm=mean(IVsm07H1)
bysort area_num: egen IVsmp=mean(IVsm06h2_07H1)
tabstat IVsm IVsmp, by(year)
drop IVsm07H1 IVsm06h2_07H1

* generate variable of base level of support for right bloc and Likud

foreach var in BRB RIGHTBLOC Plikud Plabor Pib Pkadima Pbaityehudi Pshas Pmerez turnout	{
	bysort uniqueid: egen `var'0 = mean(`var') if yr<5
	bysort uniqueid: egen `var'Pre = mean(`var'0)
	drop `var'0
	}

* use LERI score to calculate mean ideology support at baseline 
table year uniqueid if uniqueid<6, c(mean leri_score )	

foreach var in leri_AVscore leri_score{
	bysort uniqueid: egen `var'0 = mean(`var') if yr<5
	bysort uniqueid: egen `var'Pre = mean(`var'0)
	drop `var'0
	}
	
	
xtset uniqueid yr
sort uniqueid yr	
estimates drop _all
		
*******************************************
* Create dataset with 4 elections periods *
******************************************* 

replace period ="1" if period==""
replace period ="1" if period=="2006"
replace period ="2" if period=="2009"
replace period ="3" if period=="2013"
replace period ="4" if period=="2015"
destring period, replace

sort uniqueid yr
tsset uniqueid yr

* Collapsing

collapse area_num semel_yeshuv ALL_rightbloc RIGHTBLOC BRB IHE israelhayom_percent_cumulative yediot_percent Plikud Plabor Pib Pkadima Pbaityehudi Pshas Pmerez potential voters turnout religion_pcnt_08 ///
europe_pcnt_08  matriccert_pcnt_08 national_pop lpop age_median_08  asia_pcnt_08 pop_share1829 pop_share3049 pop_share5065 pop_share66 ///
ltd travel_dist travel_time  IVym IVall IVsm IVsmp otherpapers2006 ///
leri_AVscore leri_score , by(uniqueid period)

lab define period 1 "Pre 2007" 2 "2009 elections" 3 "2013 elections" 4 "2015 elections", modify
lab value period period
tab period, m

sort uniqueid period
tsset uniqueid period

preserve
keep uniqueid national_pop period
keep if period==2
	tempfile pop
	sa "`pop'"	
restore
	
merge m:1 uniqueid using "`pop'", update
drop _m

sort uniqueid period

foreach var in IHE BRB RIGHTBLOC Plikud Plabor Pib Pkadima Pbaityehudi Pshas Pmerez turnout {
	gen l`var' = l.`var'
	gen `var'D1 = `var'-l.`var'
	gen l2`var' = l2.`var'
	gen `var'D2 = `var'-l2.`var'
	gen l3`var' = l3.`var'
	gen `var'D3 = `var'-l3.`var'
	drop l`var' l2`var' l3`var'
	}
	
* generate variable of base level of support for right bloc and Likud

foreach var in BRB RIGHTBLOC Plikud Plabor Pib Pkadima Pbaityehudi Pshas Pmerez turnout	leri_AVscore leri_score {
	gen `var'0 = `var' if period==1
	bysort uniqueid: egen `var'Pre = mean(`var'0)
	}

su BRBPre PlikudPre RIGHTBLOCPre PlaborPre leri_AVscorePre leri_scorePre
	
* create an indicator of whther a locality votes more/less right to right parties compared to country median in pre-IH launch period

egen median_BRB   = median(BRB0)
gen right0 = BRB0 > median_BRB if period==1
bysort uniqueid: egen right=mean(right0)
tab right

drop median_BRB BRB0 RIGHTBLOC0 Plikud0 Plabor0 Pib0 Pkadima0 Pbaityehudi0 Pshas0 Pmerez0 turnout0

* create three level category for right, left and centrist locality based on baseline right block baseline vote share

xtile BRB0 = BRBPre if period==1 , n(3)
by uniqueid: egen BRBCat=mean(BRB0)
lab define BRBCat 1 "Left" 2 "Center" 3 "Right", modify
lab value BRBCat BRBCat
tabstat BRBPre, by(BRBCat)
drop BRB0

list IHED1 IHE israelhayom_percent_cumulative BRBD1 BRB period in 1/10 	

* create three level category for right, left and centrist locality based on LERI score

xtile LERI0 = leri_scorePre if period==1 , n(3)
by uniqueid: egen LERICat=mean(LERI0)
lab define LERICat 1 "Left" 2 "Center" 3 "Right", modify
lab value LERICat LERICat
drop LERI0
tab LERICat

xtile LERIAV0 = leri_AVscorePre if period==1 , n(3)
by uniqueid: egen LERIAVCat=mean(LERIAV0)
lab define LERIAVCat 1 "Left" 2 "Center" 3 "Right", modify
lab value LERIAVCat LERIAVCat
tabstat leri_scorePre leri_AVscorePre, by(LERIAVCat)
drop LERIAV0
tab LERIAVCat


* crate log IH

gen lIHE=log(IHE)
lab var lIHE "IH (log)"
ren israelhayom_percent_cumulative IHEC
replace IHEC= IHE if period==2


tsset uniqueid period
sort uniqueid period
	
* We define covariates

gl interactions i.period#c.ltd i.period#c.lpop i.period#c.matriccert_pcnt_08 i.period#c.europe_pcnt_08 i.period#c.pop_share1829 i.period#c.pop_share3049 i.period#c.pop_share5065 i.period#c.pop_share66 i.period#c.religion_pcnt i.period#c.asia_pcnt_08
su $interactions

gl covs ltd lpop matriccert_pcnt_08 europe_pcnt_08 pop_share1829 pop_share3049 pop_share5065 pop_share66 asia_pcnt_08 religion_pcnt
su $covs	
	
**********************************************************
* Regressions on attentiveness in different IV in levels *
**********************************************************

estimates drop _all

	foreach var in BRB Plikud {
	
		ivreg2 `var' i.period#c.BRBPre (IHE = otherpapers2006) [aw=potential], cl(area_num)
 			estadd local covs "no"	
			estadd local base "yes"
			capture est sto `var'1	


		ivreg2 `var' i.period#c.`var'Pre $interactions (IHE = otherpapers2006) [aw=potential], cl(area_num) 	
			estadd local covs "yes"	
			estadd local base "yes"
			capture est sto `var'2
		}	
	
	* Outsheeting results to create Table SI-15
	
	# delimit ;
			
			esttab BRB1 BRB2 Plikud1 Plikud2
			using "Tables/Table_SI-15.tex", replace
			keep(IHE _cons)
			cells(b(fmt(%5.3f) star) se(fmt(%5.3f) par))
			starlevels(* .10 ** .05 *** .01) 
			mgroups("\textbf{Right bloc}" "\textbf{Likud}", pattern(1 0 1 0)
			span prefix(\multicolumn{@span}{c}{) suffix(}) erepeat(\cmidrule(lr){@span})) nomtitles
			varlabels(IHE "IH exposure" _cons "Constant")
			stats(base covs r2 N, labels("Base DV" "Covariates" "R2" "N")
			fmt(0 0 2 0)) collabels(none) label booktabs nonotes;
			
			#delimit cr		
	


